/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package View;

import Controller.CustomBoardController;
import Controller.MVC;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

/**
 *
 * @author otb30
 */
public class ImagePanel extends JPanel{
    private BufferedImage img;
    private JPanel middlePanel;
    private JButton newBtn, loadBtn, helpBtn, quitBtn;
    private Font defFont = new Font("Dialog", Font.PLAIN, 20);
    private JFrame homePage;




    public ImagePanel()
    {
        setLayout(new FlowLayout());
        try{
            img = ImageIO.read(getClass().getResource("newboard.jpeg"));
           }
        catch(Exception e) {}
        repaint();

        addComponents();
        

    }

    @Override
    public void paintComponent(Graphics g)
    {
        this.paintComponents(g);
        g.drawImage(img, 0, 0, this.getWidth(), this.getHeight(), null);
    }

    private void addComponents() {

        GridLayout layout = new GridLayout(5,0);
        layout.setVgap(20);
        middlePanel = new JPanel(layout);

        newBtn = new JButton("NEW GAME");
        newBtn.setBackground(Color.red);
        newBtn.setForeground(Color.blue);
        newBtn.setFont(defFont);

        loadBtn = new JButton("LOAD GAME");
        loadBtn.setBackground(Color.blue);
        loadBtn.setForeground(Color.red);
        loadBtn.setFont(defFont);

        helpBtn = new JButton("HELP");
        helpBtn.setBackground(Color.red);
        helpBtn.setForeground(Color.blue);
        helpBtn.setFont(defFont);

        quitBtn = new JButton("QUIT");
        quitBtn.setBackground(Color.blue);
        quitBtn.setForeground(Color.red);
        quitBtn.setFont(defFont);

        middlePanel.add(newBtn);
        middlePanel.add(loadBtn);
        middlePanel.add(helpBtn);
        middlePanel.add(quitBtn);
        middlePanel.setOpaque(false);

        middlePanel.setBorder(BorderFactory.createEmptyBorder(70,0,0,0));
        add(middlePanel);


        homePage = new JFrame();
        homePage.add(this);
        homePage.setPreferredSize(new Dimension(620, 500));
        homePage.pack();
        homePage.setLocationRelativeTo(null);
        homePage.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        homePage.setVisible(true);
        homePage.setResizable(false);
        homePage.setLocationRelativeTo(null);

      //  throw new UnsupportedOperationException("Not yet implemented");
    }
    
    public void killPanel() {
        homePage.dispose();
    }
    
    public void addImagePanelList(ActionListener mal) {
        newBtn.addActionListener(mal);
        loadBtn.addActionListener(mal);
        helpBtn.addActionListener(mal);
        quitBtn.addActionListener(mal);
        
    }    
     
//     public void showCustomBoard() 
//     {
//        customView.setVisible(true);
//            
//    }
}//End class
